package b.acct.impl

import b.acct.api.CC账户
import b.utils.formats.JsonFormats
import com.lightbend.lagom.scaladsl.persistence.{AggregateEvent, AggregateEventTag}
import play.api.libs.json.{Format, Json}

/**
  * 贲国称 于 2016/12/9 创建。
  */

trait T账户Event extends AggregateEvent[T账户Event] {
  override def aggregateTag(): AggregateEventTag[T账户Event] = O账户Event.TAG
}
object O账户Event {
  val TAG: AggregateEventTag[T账户Event] = AggregateEventTag[T账户Event]
}

case class CC新账户Event(v账户: CC账户) extends T账户Event
case class CC账户新余额Event(v事务ID: Long, v账号: String, v新余额: BigDecimal) extends T账户Event
case class CC账户余额恢复Event(v事务ID: Long, v账号: String) extends T账户Event
case class CC账户余额预留Event(v事务ID: Long, v账号: String, v对方账号: String, v金额: BigDecimal) extends T账户Event
object CC新账户Event {
  implicit val format1: Format[CC新账户Event] = Json.format
}
object CC账户新余额Event {
  implicit val format1: Format[CC账户新余额Event] = Json.format
}
object CC账户余额恢复Event {
  implicit val format1: Format[CC账户余额恢复Event] = Json.format
}
object CC账户余额预留Event {
  implicit val format1: Format[CC账户余额预留Event] = Json.format
}
object E余额变化方向 extends Enumeration {
  val e增加 = Value("+")
  val e减少 = Value("-")
  private val nameOfValues = Seq[String]("增加", "减少")
  def nameOf(v: Value): String = nameOfValues(v.id)
  implicit val format: Format[Value] = JsonFormats.enumFormat(E余额变化方向)
}